﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Threading;
using RAD.Modules.UI.Interfaces;

namespace RAD.Modules.UI.Views
{
    /// <summary>
    /// Interaction logic for About.xaml
    /// </summary>
    public partial class AboutView : Window, IAboutView
    {
        public AboutView()
        {
            InitializeComponent();
            this.Closing += AboutView_Closing;
            this.Topmost = true;
        }

        void AboutView_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            e.Cancel = true;
          
            // Этот метод необходим, чтобы обеспечить в WPF нарантированную работу отображения/сокрытия окна.
            Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, (DispatcherOperationCallback)delegate(object o)
            {
                this.Hide();
                return null;
            }, null);

        }

        #region IAboutView Members

        public void ShowView()
        {
            if (this.Owner == null)
            {
                this.Owner = Application.Current.MainWindow;
            }
            this.ShowDialog();
        }        
        #endregion

        #region IAboutView Members


        public event EventHandler<EventArgs> AboutViewClose;

        #endregion

        private void _okBtn_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }
    }
}
